<script>
  var arithmeticTriplets = function (nums, diff) {
    let ans = 0;
    let n = nums.length;
    for (let i = 0; i < n; i++) {
      const ni = nums[i];
      for (let j = i + 1; j < n; j++) {
        const nj = nums[j];
        if (nj - ni === diff) {
          for (let x = j + 1; x < n; x++) {
            const nx = nums[x];
            if (nx - nj === diff) {
              ans++;
              break;
            }
          }
        }
      }
    }
    return ans;
  };
  console.log(arithmeticTriplets([0, 1, 4, 6, 7, 10], 3));
</script>